import {useAxios} from '@/hooks/web/useAxios'
import {parseStrEmpty} from '@/utils'
// import type { UserLoginType, UserType } from './types'

const request = useAxios()
// 查询用户列表
export const listUser = (params) => {
    return request.get({
        url: '/system/user/list',
        params
    })
}

// 用户密码重置
export const resetUserPwd = (userName: string, password: string | number) => {
    const data = {
        userName,
        password
    }
    return request.put({
        url: '/system/user/resetPwd',
        data
    })
}

// 查询用户详细
export const getUser = (userId?: number) => {
    return request.get({
        url: '/system/user/' + parseStrEmpty(userId)
    })
}

// 新增用户
export const addUser = (data) => {
    return request.post({
        url: '/system/user',
        data
    })
}

// 修改用户
export const updateUser = (data) => {
    return request.put({
        url: '/system/user',
        data
    })
}

// 删除用户
export const delUser = (userId: number) => {
    return request.delete({
        url: '/system/user/' + userId
    })
}

// 获取部门树列表
export const getDeptTree = () => {
    return request.get({
        url: '/system/dept/deptTree'
    })
}

// 验证用户密码是否初始密码
export const verifyPassword = () => {
    return request.get({
        url: '/system/user/verifyPwd'
    })
}